package com.pratik.gedcom.fileutil.implementation;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import com.pratik.gedcom.fileutil.interfaces.GedcomFileUtil;

public class GedcomeFileUtilsImplementation implements GedcomFileUtil {

	@Override
	public List<String> getTokenList(File gedcomFile) {
		List<String> tokenList = new ArrayList<String>();
		try {
			Scanner scanner = new Scanner(gedcomFile);
			while (scanner.useDelimiter("\n").hasNext()) {
				String token = scanner.useDelimiter("\n").next().trim();
				if (!token.isEmpty()) {
					tokenList.add(token);
				}
			}
		} catch (FileNotFoundException e) {
			System.out.println("file is not found");
		}
		return tokenList;
	}

}
